home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / basic2 / pro19 / qbinput.doc < prev    next >
Text File  |  1987-03-06  |  3KB  |  74 lines

  1. QBINPUT.SUB - subprogram to build input string in a controlled manner
  2.  
  3. written by lee bernbaum
  4.            3478 stone
  5.            memphis, tn 38118
  6.            reachable at GEMS BBS  (901)-278-4367
  7.  
  8. No Charge - use it as you see fit - distribute it freely
  9.  
  10. What It Is:
  11.  
  12. QBINPUT is a Quikbasic SUB-PROGRAM that can be called to handle input in
  13. a reasonably controlled manner, returning a string of a predefined length.
  14. The input field is filled with whatever character you specify.  You can
  15. control whether or not a CR is required when maximum length is reached,
  16. thus providing rudimentary word wrapping (until you backspace all the way
  17. to the beginning of the string...previous line's X,Y values are not saved).
  18. The cursor is always blinking where the next character will go.
  19.  
  20. This routine was written because the INPUT command just does not suffice
  21. for controlled input,  and INSTR$ can be a nuisance.
  22.  
  23. How to use it:
  24.  
  25. Either merge this code into your Quikbasic program directly,  or remember to
  26. include it via the QB Metacommand REM $INCLUDE: 'QBINPUT.SUB'.  Or you can
  27. compile it to object level,  and LINK to the .OBJ file, by doing the
  28. following:
  29.  
  30. QB YOURPROG.BAS,,,/E/X/O
  31. QB QBINPUT.SUB,,,/O
  32. LINK YOURPROG+QBINPUT
  33.  
  34. You call this routine from within a program with the command:
  35.  
  36. CALL GETINP(IX,IY,MAXLEN,FILL,GETKEY$,WRAP)
  37.  
  38. where   IX       = The line number (between 1 and 23)
  39.         IY       = The column number (between 1 and (79-MAXLEN))
  40.         MAXLEN   = The desired length of the string
  41.         FILL     = The ASCII decimal value of the desired filler in the
  42.                    input area. Example ASCII 42 = *,  thus a FILL of 42
  43.                    would create an input area filled with asteriks to
  44.                    show the user the field length.
  45.         GETKEY$  = The input string returned to the calling program
  46.         WRAP     = 1=enable wrapping;anything else reuires a CR to end input
  47.  
  48. A sample use might be as follows:
  49. Get Input of a Drive Specification
  50.  
  51. RF=7:RB=0:INF=1:INB=7          set regular and input colors, if desired
  52. COLOR RF,RB                    toggle regular screen color
  53. IX=5                           set row number for line 5 of display
  54. WRAP=1                         enable word wrap
  55. MAXLEN=25                      desired input string maximum 25 characters
  56. FILL=35                        ASCII code for #,  desired fill character
  57. GETKEY$=""                     doesn't matter - just use first time routine
  58.                                'is called - GETKEY$ is recycled after that
  59. PRMPT$=chr$(7)+"Please Specify Drive Path: "   create a prompt
  60. LOCATE IX,15:PRINT PRMPT$                      position\print prompt in col 15
  61. IY=15+(LEN(PRMPT$))                            calculate input start column
  62. COLOR INF,INB                  set for input field colors
  63. CALL GETINP(IX,IY,MAXLEN,FILL,GETKEY$,WRAP)    call the routine
  64. IF.......the necessary logic to screen a VALID drive path type string
  65. COLOR RF,RB                    reset screen color
  66. Whatever program would do next here
  67.  
  68. I have found this routine useful in several of my own programs.  Between this
  69. sub-program and event trapping of defined keys,  I find it very easy to put
  70. a tight grip on what my users can do to a program.
  71.  
  72. Hope you find it useful.
  73.  
  74.